package com.yuanfengPlus.basicInfoManage.loginAndAuthentication.controller;

import com.yuanfengPlus.basicInfoManage.loginAndAuthentication.service.BlogLoginService;
import com.yuanfengPlus.utils.Result ;
import com.yuanfengPlus.basicInfoManage.loginAndAuthentication.model.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "登录接口")
public class BlogLoginController {
    @Autowired
    private BlogLoginService blogLoginService;


    /**
     * blog登录功能
     * @param user
     * @return
     */
    @PostMapping("/login")
    @ApiOperation(value = "登录接口")
    public Result login(@RequestBody User user){
        return blogLoginService.login(user);
    }

    /**
     * blog注册功能
     * @param user
     * @return
     */
    @PostMapping("/addUser")
    @ApiOperation(value = "注册接口")
    public Result addUser(@RequestBody User user){
        return blogLoginService.addUser(user);
    }
    //登出功能

    /**
     *  登出功能
     * @param userID
     * @return
     */
    @PostMapping("/logout")
    @ApiOperation(value = "登出接口")
    public Result logout(String userID){
        return blogLoginService.logout(userID);
    }
}